You are here: Symbol Reference > Dew Namespace > Dew.Stats Namespace > Dew.Stats.Units Namespace > Classes > RegModels Class > RegModels Methods > RegModels.MulLinFit Method
Dew Stats for .NET
ContentsIndexHome
PreviousUpNext
RegModels.MulLinFit Method

Fits multiple linear equations to data.

Syntax
C#
Visual Basic
public static void MulLinFit([In] TVec B, [In] TMtx X, [In] TVec Y, bool Constant, [In] TVec Weights);
Parameters 
Description 
[In] TVec B 
Returns regression coefficients for multiple linear function. 
[In] TMtx X 
Vector of independent variable. 
[In] TVec Y 
Vector of dependent variable. 
bool Constant 
If true then intercept term b(0) will be included in calculations. If false, set intercept term b(0) to 0.0. 
[In] TVec Weights 
Weights (optional). Weights are used only if they are set. 

The routine fits equations to data by minimizing the sum of squared residuals. The observed values obey the following equation: 

 

where X is matrix, Y, B are vectors.

In the following example we generate some data. Then we fit multiple linear function to this data and retreive it's regression coefficients.

using Dew.Math; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Matrix X = new Matrix(0,0); Vector Y = new Vector(0); Vector B = new Vector(0); X.SetIt(3,2,false,new double[]{1.0, 2.0, -3.2, 2.5, 8.0, -0.5}); Y.SetIt(3,new double[] {-3.0, 0.25, 9.0}); RegModels.MulLinFit(B,X,Y,true,null); // B = (18.646428571, -1.9464285714, -9.85 ) } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!